//package cn.bgs.mq.MqConfig;
//
//import org.springframework.amqp.core.*;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.util.HashMap;
//
///**
// * @Author:YiChen
// * @program: IntelliJ IDEA
// * @Description:
// * @Created 2021/9/27-19:47
// * 直接交换机配置，用户上传图书后给用户发送上传成功的消息
// */
//
//@Configuration
//public class DelayedQueueConfig {
//
//    //队列
//    public static final String DELAYED_QUEUE_NAME="order.queue";
//    //交换机
//    public static final String DELAYED_EXCHANGE_NAME="order.exchange";
//    //routingKing
//    public static final String DELAYED_ROUTING_KEY="order.rotingkey";
//
//
//    //死信队列
//    public static final String DEAD_LETTER_QUEUE="dead.queue";
//    //死信交换机
//    public static final String DEAD_LETTER_EXCHANGE="dead.exchange";
//    //routingKing
//    public static final String DEAD_ROUTING_KEY="dead.rotingkey";
//
//
//
//    //声明队列
//    @Bean
//    public Queue directQueue(){
//        //绑定死信交换机
//        HashMap<String,Object> hashMap = new HashMap<>(3);
//        hashMap.put("x-dead-letter-exchange",DEAD_LETTER_EXCHANGE);
//        hashMap.put("x-dead-letter-routing-key",DEAD_ROUTING_KEY);
//        hashMap.put("x-message-ttl",10000);
//        return new Queue(DELAYED_QUEUE_NAME,true,false,false,hashMap);
//    }
//    //声明死信队列
//    @Bean("queueDead")
//    public Queue queueDead(){
//        return QueueBuilder.durable(DEAD_LETTER_QUEUE).build();
//    }
//
//    //声明直接交换机
//    @Bean
//    public DirectExchange directExchange(){
//        return new DirectExchange(DELAYED_EXCHANGE_NAME,true,false,null);
//    }
//    //死信交换机
//    @Bean
//    public DirectExchange deadExchange(){
//        return new DirectExchange(DEAD_LETTER_EXCHANGE);
//    }
//
//
//    //绑定交换机和队列
//    @Bean
//    public Binding delBindingDel(@Qualifier("directQueue") Queue directQueue, @Qualifier("directExchange") DirectExchange directExchange){
//
//        return BindingBuilder.bind(directQueue).to(directExchange).with(DELAYED_ROUTING_KEY);
//
//    }
//
//    //死信交换机和死信队列
//    @Bean
//    public Binding deadBindingDel(@Qualifier("queueDead") Queue queueDead, @Qualifier("deadExchange") DirectExchange deadExchange){
//
//        return BindingBuilder.bind(queueDead).to(deadExchange).with(DEAD_ROUTING_KEY);
//    }
//}
